yii2 除了主页其他的页面都是404 Not Found


今天在centos搭建yii2好不容易调试出了主页显示,但是除了主页其他的页面都是404 Not Found,很明显是路由问题。
yii2官方的的git给出了解决方法

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Use the following configuration in Apache's httpd.conf file or within a virtual host configuration. Note that you should replace path/to/basic/web with the actual path for basic/web.
# Set document root to be "basic/web"
DocumentRoot "path/to/basic/web"
<Directory "path/to/basic/web">
# use mod_rewrite for pretty URL support
RewriteEngine on
# If a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward the request to index.php
RewriteRule . index.php
# ...other settings...
</Directory>

这是我服务器上的httpd.conf文件修改的截图:

enter description here

前台和后台都要添加,添加完路由才正常。不知道为什么非要在apache的配置文件中添加,web目录下的.htaccess不起作用.

热评文章